package cn.cena.web.controller;

import cn.cena.doc.CourseDoc;
import cn.cena.repository.CourseElasticSearchRepository;
import cn.cena.service.ICourseSearchService;
import cn.cena.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es")
public class SearchController {

    @Autowired
    private ICourseSearchService courseSearchService;

    /**
     * 课程上线保存到ES
     * @param doc
     * @return
     */
    @PostMapping("/course/online")
    public AjaxResult onlineCourse(@RequestBody CourseDoc doc){
        courseSearchService.courseOnline(doc);
        return AjaxResult.me();
    }
}
